import { SerializeStream } from "../../Framework/Serialize/SerializeStream";
import { SServerKey } from "./SServerKey";
import { SeqServerKeyHelper } from "./SeqServerKeyHelper";
//class CrossMassacreServerKeyHelper

export class CrossMassacreServerKeyHelper {
  public static write(
    stream: SerializeStream,
    arg2: Map<SServerKey, SServerKey[]> /* flash.utils.Dictionary */
  ): void {
    if (arg2) {
      stream.writeSize(arg2.size);
      for (let [key, value] of arg2.entries()) {
        key.__write(stream);
        SeqServerKeyHelper.write(stream, value);
      }
    } else {
      stream.writeSize(0);
    }
    return;
  }

  public static read(
    arg1: SerializeStream
  ): Map<SServerKey, any> /* flash.utils.Dictionary */ {
    var loc4 = null;
    var loc5 = null;
    var loc1 = new Map<SServerKey, SServerKey[]> /* flash.utils.Dictionary */();
    var loc2 = arg1.readSize();
    var loc3 = 0;
    while (loc3 < loc2) {
      (loc4 = new SServerKey()).__read(arg1);
      loc5 = SeqServerKeyHelper.read(arg1);
      loc1.set(loc4, loc5);
      ++loc3;
    }
    return loc1;
  }
}
